package two_xia.ex9.Demo06;

public class MementoPattern {
    public static void main(String[] args) {
        Chessman chessman = new Chessman("炮");
        Caretaker caretaker = new Caretaker();

        // 移动棋子并保存状态
        chessman.showState();
        caretaker.save(chessman.saveState());
        chessman.move();
        chessman.showState();

        // 悔棋
        chessman.restoreState(caretaker.undo());
        chessman.showState();
    }
}